package edu.uwg.lewiswilliams.android.lab3;

import android.app.ListActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.ArrayAdapter;
import android.widget.Toast;

public class StudentListActivity extends ListActivity {
   
	private String[] students = new String[] {	"John Doe", "Fred Flintstone", "Jane Doe", "Bugs Bunny", 
												"Daffy Duck", "Road Runner", "Sally Mae", "Freddie Mac", 
												"Wilma Flintstone", "Barney Rubble", "Foghorn Leghorn", "Tweety Bird"};
	
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.main);
        setListAdapter(new ArrayAdapter<String>(this, R.layout.students, this.students));
    }
    
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.studentsoption, menu);
    return true;
    }
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
    	switch (item.getItemId()) {
    	case R.id.addStudent:
    		Toast.makeText(getApplicationContext(), "Adding student",
    				Toast.LENGTH_SHORT).show();
    		return true;
    	case R.id.deleteAllStudents:
    		Toast.makeText(getApplicationContext(), "Deleting all students",
    				Toast.LENGTH_SHORT).show();
    		return true;
    	default:
    		return super.onOptionsItemSelected(item);
    	}
    }
}